package com.ruoyi.project.orderSystem.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.orderSystem.domain.StationItemFile;
import com.ruoyi.project.orderSystem.service.IStationItemFileService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 站点巡检文件Controller
 * 
 * @author wangshuo
 * @date 2021-01-24
 */
@RestController
@RequestMapping("/orderSystem/itemFile")
public class StationItemFileController extends BaseController
{
    @Autowired
    private IStationItemFileService stationItemFileService;

    /**
     * 查询站点巡检文件列表
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:itemFile:list')")
    @GetMapping("/list")
    public TableDataInfo list(StationItemFile stationItemFile)
    {
        startPage();
        List<StationItemFile> list = stationItemFileService.selectStationItemFileList(stationItemFile);
        return getDataTable(list);
    }

    /**
     * 导出站点巡检文件列表
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:itemFile:export')")
    @Log(title = "站点巡检文件", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StationItemFile stationItemFile)
    {
        List<StationItemFile> list = stationItemFileService.selectStationItemFileList(stationItemFile);
        ExcelUtil<StationItemFile> util = new ExcelUtil<StationItemFile>(StationItemFile.class);
        return util.exportExcel(list, "itemFile");
    }

    /**
     * 获取站点巡检文件详细信息
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:itemFile:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(stationItemFileService.selectStationItemFileById(id));
    }

    /**
     * 新增站点巡检文件
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:itemFile:add')")
    @Log(title = "站点巡检文件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StationItemFile stationItemFile)
    {
        return toAjax(stationItemFileService.insertStationItemFile(stationItemFile));
    }

    /**
     * 修改站点巡检文件
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:itemFile:edit')")
    @Log(title = "站点巡检文件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StationItemFile stationItemFile)
    {
        return toAjax(stationItemFileService.updateStationItemFile(stationItemFile));
    }

    /**
     * 删除站点巡检文件
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:itemFile:remove')")
    @Log(title = "站点巡检文件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stationItemFileService.deleteStationItemFileByIds(ids));
    }
}
